package com.example.tnot.Teacher.Homepart.InternalFragment.Frequent.Agent.Adapter;

import android.util.SparseArray;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.tnot.Teacher.Homepart.InternalFragment.Frequent.Agent.AgentInternalFragment;
import com.example.tnot.Teacher.MinePart.InternalFragment.collection.CollectInternalFragment;

public class vpAgent extends FragmentStateAdapter {
    public final String[] tabs = {"全部", "作业", "考试", "任务"};
    private SparseArray<AgentInternalFragment> fragmentReferences = new SparseArray<>();

    public vpAgent(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);

    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        AgentInternalFragment fragment = AgentInternalFragment.newInstance(tabs[position]);
        fragmentReferences.put(position, fragment);
        return fragment;
    }
    @Override
    public int getItemCount() {
        return tabs.length;
    }



    public AgentInternalFragment getFragmentAtPosition(int position) {
        return fragmentReferences.get(position);
    }

}

